#!/bin/bash

# 设置变量
BUILD_DIR="build"
PCAP_DIR="pcaps"
LOG_DIR="logs"
P4C="p4c-bm2-ss"
P4C_ARGS="--p4runtime-files $BUILD_DIR/arp.p4.p4info.txtpb"
RUN_SCRIPT="../../utils/run_exercise.py"
TOPO="topology.json"
DEFAULT_PROG="arp.p4"
DEFAULT_JSON="$BUILD_DIR/${DEFAULT_PROG%.p4}.json"

# 创建目录
mkdir -p $BUILD_DIR $PCAP_DIR $LOG_DIR

# 编译P4程序
$P4C --p4v 16 $P4C_ARGS -o $DEFAULT_JSON $DEFAULT_PROG

# 运行练习
sudo PATH=$PATH python3 $RUN_SCRIPT -t $TOPO -j $DEFAULT_JSON